package logic

import (
	"context"
	"mall/mallrpc/mallrpc"

	"mall/api/internal/svc"
	"mall/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewShLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShLogic {
	return &ShLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ShLogic) Sh(req *types.ShRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	sh, err := l.svcCtx.Mallrpc.Sh(l.ctx, &mallrpc.ShRequest{
		Userid: int64(req.Userid),
		Liss:   req.Liss,
		Down:   req.Down,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    400,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "审核成功",
		Code:    200,
		Data:    sh,
	}, nil
}
